﻿using IOP.Protocols.MQTT.Package;
using System;

namespace IOP.Protocols.MQTT
{
    /// <summary>
    /// MQTT包异常
    /// </summary>
    public class MQTTPackageException : Exception
    {
        /// <summary>
        /// 错误信息
        /// </summary>
        private string Error;
        /// <summary>
        /// 内联异常
        /// </summary>
        private new readonly Exception InnerException;
        /// <summary>
        /// 当前MQTT包
        /// </summary>
        private IMQTTPackage Package;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="message"></param>
        public MQTTPackageException(string message) : base(message) { }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="package"></param>
        /// <param name="message"></param>
        public MQTTPackageException(IMQTTPackage package, string message) : base(message)
        {
            Package = package;
            Error = message;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="package"></param>
        /// <param name="message"></param>
        /// <param name="innerException"></param>
        public MQTTPackageException(IMQTTPackage package, string message, Exception innerException)
            : base(message, innerException)
        {
            Error = message;
            Package = package;
            InnerException = innerException;
        }
    }
}
